package com.learn;

import com.learn.beans.OtherBeans;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 带着问题学源码
 */
@EnableAsync
@EnableMBeanExport
@ComponentScan
@Import(OtherBeans.class)
public class Application {
    public static void main(String[] args) {
        /**
         * ⭕️ Spring容器启动时内置Bean是怎么被加载的？
         * ⭕️ Spring容器启动时手动配置Bean是怎么被扫描的？
         * ⭕️ 涉及到的反射加载Bean和SPI机制在哪里体现？
         *      DefaultListableBeanFactory的静态代码块中
         */
        // 【单一职责】ApplicationContext的常用实现类有ClassPathXmlApplicationContext、FileSystemXmlApplicationContext、AnnotationConfigApplicationContext，每个实现类的实现方式不同，类名做到见名知意
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Application.class);
        
        String[] beanNames = applicationContext.getBeanDefinitionNames();
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }
		
		/*
		org.springframework.context.annotation.internalConfigurationAnnotationProcessor
		org.springframework.context.annotation.internalAutowiredAnnotationProcessor
		org.springframework.context.annotation.internalCommonAnnotationProcessor
		org.springframework.context.event.internalEventListenerProcessor
		org.springframework.context.event.internalEventListenerFactory
		application
		userDao
		userService
		...
		*/
    }
}
